home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / yacc.arc / PARSER.Y < prev    next >
Text File  |  1985-09-04  |  16KB  |  793 lines

  1.  
  2. %token CHAR CCL NCCL STR DELIM SCON ITER NEWE NULLS
  3. %left SCON '/' NEWE
  4. %left '|'
  5. %left '$' '^'
  6. %left CHAR CCL NCCL '(' '.' STR NULLS
  7. %left ITER
  8. %left CAT
  9. %left '*' '+' '?'
  10.  
  11. %{
  12. # include "ldefs.c"
  13. %}
  14. %%
  15. %{
  16. int i;
  17. int j,k;
  18. int g;
  19. char *p;
  20. %}
  21. acc    :    lexinput
  22.     ={    
  23. # ifdef DEBUG
  24.         if(debug) sect2dump();
  25. # endif
  26.     }
  27.     ;
  28. lexinput:    defns delim prods end
  29.     |    defns delim end
  30.     ={
  31.         if(!funcflag)phead2();
  32.         funcflag = TRUE;
  33.     }
  34.     | error
  35.     ={
  36. # ifdef DEBUG
  37.         if(debug) {
  38.             sect1dump();
  39.             sect2dump();
  40.             }
  41. # endif
  42.         }
  43.     ;
  44. end:        delim | ;
  45. defns:    defns STR STR
  46.     ={    scopy($2,dp);
  47.         def[dptr] = dp;
  48.         dp += slength($2) + 1;
  49.         scopy($3,dp);
  50.         subs[dptr++] = dp;
  51.         if(dptr >= DEFSIZE)
  52.             error("Too many definitions");
  53.         dp += slength($3) + 1;
  54.         if(dp >= dchar+DEFCHAR)
  55.             error("Definitions too long");
  56.         subs[dptr]=def[dptr]=0;    /* for lookup - require ending null */
  57.     }
  58.     |
  59.     ;
  60. delim:    DELIM
  61.     ={
  62. # ifdef DEBUG
  63.         if(sect == DEFSECTION && debug) sect1dump();
  64. # endif
  65.         sect++;
  66.         }
  67.     ;
  68. prods:    prods pr
  69.     ={    $$ = mn2(RNEWE,$1,$2);
  70.         }
  71.     |    pr
  72.     ={    $$ = $1;}
  73.     ;
  74. pr:    r NEWE
  75.     ={
  76.         if(divflg == TRUE)
  77.             i = mn1(S1FINAL,casecount);
  78.         else i = mn1(FINAL,casecount);
  79.         $$ = mn2(RCAT,$1,i);
  80.         divflg = FALSE;
  81.         casecount++;
  82.         }
  83.     | error NEWE
  84.     ={
  85. # ifdef DEBUG
  86.         if(debug) sect2dump();
  87. # endif
  88.         }
  89. r:    CHAR
  90.     ={    $$ = mn0($1); }
  91.     | STR
  92.     ={
  93.         p = $1;
  94.         i = mn0(*p++);
  95.         while(*p)
  96.             i = mn2(RSTR,i,*p++);
  97.         $$ = i;
  98.         }
  99.     | '.'
  100.     ={    symbol['\n'] = 0;
  101.         if(psave == FALSE){
  102.             p = ccptr;
  103.             psave = ccptr;
  104.             for(i=1;i<'\n';i++){
  105.                 symbol[i] = 1;
  106.                 *ccptr++ = i;
  107.                 }
  108.             for(i='\n'+1;i<NCH;i++){
  109.                 symbol[i] = 1;
  110.                 *ccptr++ = i;
  111.                 }
  112.             *ccptr++ = 0;
  113.             if(ccptr > ccl+CCLSIZE)
  114.                 error("Too many large character classes");
  115.             }
  116.         else
  117.             p = psave;
  118.         $$ = mn1(RCCL,p);
  119.         cclinter(1);
  120.         }
  121.     | CCL
  122.     ={    $$ = mn1(RCCL,$1); }
  123.     | NCCL
  124.     ={    $$ = mn1(RNCCL,$1); }
  125.     | r '*'
  126.     ={    $$ = mn1(STAR,$1); }
  127.     | r '+'
  128.     ={    $$ = mn1(PLUS,$1); }
  129.     | r '?'
  130.     ={    $$ = mn1(QUEST,$1); }
  131.     | r '|' r
  132.     ={    $$ = mn2(BAR,$1,$3); }
  133.     | r r %prec CAT
  134.     ={    $$ = mn2(RCAT,$1,$2); }
  135.     | r '/' r
  136.     ={    if(!divflg){
  137.             j = mn1(S2FINAL,-casecount);
  138.             i = mn2(RCAT,$1,j);
  139.             $$ = mn2(DIV,i,$3);
  140.             }
  141.         else {
  142.             $$ = mn2(RCAT,$1,$3);
  143.             warning("Extra slash removed");
  144.             }
  145.         divflg = TRUE;
  146.         }
  147.     | r ITER ',' ITER '}'
  148.     ={    if($2 > $4){
  149.             i = $2;
  150.             $2 = $4;
  151.             $4 = i;
  152.             }
  153.         if($4 <= 0)
  154.             warning("Iteration range must be positive");
  155.         else {
  156.             j = $1;
  157.             for(k = 2; k<=$2;k++)
  158.                 j = mn2(RCAT,j,dupl($1));
  159.             for(i = $2+1; i<=$4; i++){
  160.                 g = dupl($1);
  161.                 for(k=2;k<=i;k++)
  162.                     g = mn2(RCAT,g,dupl($1));
  163.                 j = mn2(BAR,j,g);
  164.                 }
  165.             $$ = j;
  166.             }
  167.     }
  168.     | r ITER '}'
  169.     ={
  170.         if($2 < 0)warning("Can't have negative iteration");
  171.         else if($2 == 0) $$ = mn0(RNULLS);
  172.         else {
  173.             j = $1;
  174.             for(k=2;k<=$2;k++)
  175.                 j = mn2(RCAT,j,dupl($1));
  176.             $$ = j;
  177.             }
  178.         }
  179.     | r ITER ',' '}'
  180.     ={
  181.                 /* from n to infinity */
  182.         if($2 < 0)warning("Can't have negative iteration");
  183.         else if($2 == 0) $$ = mn1(STAR,$1);
  184.         else if($2 == 1)$$ = mn1(PLUS,$1);
  185.         else {        /* >= 2 iterations minimum */
  186.             j = $1;
  187.             for(k=2;k<$2;k++)
  188.                 j = mn2(RCAT,j,dupl($1));
  189.             k = mn1(PLUS,dupl($1));
  190.             $$ = mn2(RCAT,j,k);
  191.             }
  192.         }
  193.     | SCON r
  194.     ={    $$ = mn2(RSCON,$2,$1); }
  195.     | '^' r
  196.     ={    $$ = mn1(CARAT,$2); }
  197.     | r '$'
  198.     ={    i = mn0('\n');
  199.         if(!divflg){
  200.             j = mn1(S2FINAL,-casecount);
  201.             k = mn2(RCAT,$1,j);
  202.             $$ = mn2(DIV,k,i);
  203.             }
  204.         else $$ = mn2(RCAT,$1,i);
  205.         divflg = TRUE;
  206.         }
  207.     | '(' r ')'
  208.     ={    $$ = $2; }
  209.     |    NULLS
  210.     ={    $$ = mn0(RNULLS); }
  211.     ;
  212. %%
  213. yylex(){
  214.     register char *p;
  215.     register int c, i;
  216.     char  *t, *xp;
  217.     int n, j, k, x;
  218.     static int sectbegin;
  219.     static char token[TOKENSIZE];
  220.     static int iter;
  221.  
  222. # ifdef DEBUG
  223.     yylval = 0;
  224. # endif
  225.  
  226.     if(sect == DEFSECTION) {        /* definitions section */
  227.         while(!eof) {
  228.             if(prev == '\n'){        /* next char is at begin
  229. ning of line */
  230.                 getl(p=buf);
  231.                 switch(*p){
  232.                 case '%':
  233.                     switch(c= *(p+1)){
  234.                     case '%':
  235.                         lgate();
  236.                         if(!ratfor)fprintf(fout,"# ");
  237.                         fprintf(fout,"define YYNEWLINE %
  238. d\n",ctable['\n']);
  239.                         if(!ratfor)fprintf(fout,"yylex()
  240. {\nint nstr; extern int yyprevious;\n");
  241.                         sectbegin = TRUE;
  242.                         i = treesize*(sizeof(*name)+size
  243. of(*left)+
  244.                             sizeof(*right)+sizeof(*n
  245. ullstr)+sizeof(*parent))+ALITTLEEXTRA;
  246.                         c = myalloc(i,1);
  247.                         if(c == 0)
  248.                             error("Too little core f
  249. or parse tree");
  250.                         p = c;
  251.                         cfree(p,i,1);
  252.                         name = myalloc(treesize,sizeof(*
  253. name));
  254.                         left = myalloc(treesize,sizeof(*
  255. left));
  256.                         right = myalloc(treesize,sizeof(
  257. *right));
  258.                         nullstr = myalloc(treesize,sizeo
  259. f(*nullstr));
  260.                         parent = myalloc(treesize,sizeof
  261. (*parent));
  262.                         if(name == 0 || left == 0 || rig
  263. ht == 0 || parent == 0 || nullstr == 0)
  264.                             error("Too little core f
  265. or parse tree");
  266.                         return(freturn(DELIM));
  267.                     case 'p': case 'P':    /* has overridde
  268. n number of positions */
  269.                         while(*p && !digit(*p))p++;
  270.                         maxpos = siconv(p);
  271. # ifdef DEBUG
  272.                         if (debug) printf("positions (%%
  273. p) now %d\n",maxpos);
  274. # endif
  275.                         if(report == 2)report = 1;
  276.                         continue;
  277.                     case 'n': case 'N':    /* has overridde
  278. n number of states */
  279.                         while(*p && !digit(*p))p++;
  280.                         nstates = siconv(p);
  281. # ifdef DEBUG
  282.                         if(debug)printf( " no. states (%
  283. %n) now %d\n",nstates);
  284. # endif
  285.                         if(report == 2)report = 1;
  286.                         continue;
  287.                     case 'e': case 'E':        /* has o
  288. verridden number of tree nodes */
  289.                         while(*p && !digit(*p))p++;
  290.                         treesize = siconv(p);
  291. # ifdef DEBUG
  292.                         if (debug) printf("treesize (%%e
  293. ) now %d\n",treesize);
  294. # endif
  295.                         if(report == 2)report = 1;
  296.                         continue;
  297.                     case 'o': case 'O':
  298.                         while (*p && !digit(*p))p++;
  299.                         outsize = siconv(p);
  300.                         if (report ==2) report=1;
  301.                         continue;
  302.                     case 'a': case 'A':        /* has o
  303. verridden number of transitions */
  304.                         while(*p && !digit(*p))p++;
  305.                         if(report == 2)report = 1;
  306.                         ntrans = siconv(p);
  307. # ifdef DEBUG
  308.                         if (debug)printf("N. trans (%%a)
  309.  now %d\n",ntrans);
  310. # endif
  311.                         continue;
  312.                     case 'k': case 'K': /* overriden packed 
  313. char classes */
  314.                         while (*p && !digit(*p))p++;
  315.                         if (report==2) report=1;
  316.                         cfree(pchar, pchlen, sizeof(*pch
  317. ar));
  318.                         pchlen = siconv(p);
  319. # ifdef DEBUG
  320.                         if (debug) printf( "Size classes
  321.  (%%k) now %d\n",pchlen);
  322. # endif
  323.                         pchar=pcptr=myalloc(pchlen, size
  324. of(*pchar));
  325.                         continue;
  326.                     case 't': case 'T':     /* character set
  327.  specifier */
  328.                         ZCH = atoi(p+2);
  329.                         if (ZCH < NCH) ZCH = NCH;
  330.                         if (ZCH > 2*NCH) error("ch table
  331.  needs redeclaration");
  332.                         chset = TRUE;
  333.                         for(i = 0; i<ZCH; i++)
  334.                             ctable[i] = 0;
  335.                         while(getl(p) && scomp(p,"%T") !
  336. = 0 && scomp(p,"%t") != 0){
  337.                             if((n = siconv(p)) <= 0 
  338. || n > ZCH){
  339.                                 warning("Charact
  340. er value %d out of range",n);
  341.                                 continue;
  342.                                 }
  343.                             while(!space(*p) && *p) 
  344. p++;
  345.                             while(space(*p)) p++;
  346.                             t = p;
  347.                             while(*t){
  348.                                 c = ctrans(&t);
  349.                                 if(ctable[c]){
  350.                                     if (prin
  351. table(c))
  352.                                         w
  353. arning("Character '%c' used twice",c);
  354.                                     else
  355.                                         w
  356. arning("Character %o used twice",c);
  357.                                     }
  358.                                 else ctable[c] =
  359.  n;
  360.                                 t++;
  361.                                 }
  362.                             p = buf;
  363.                             }
  364.                         {
  365.                         char chused[2*NCH]; int kr;
  366.                         for(i=0; i<ZCH; i++)
  367.                             chused[i]=0;
  368.                         for(i=0; i<NCH; i++)
  369.                             chused[ctable[i]]=1;
  370.                         for(kr=i=1; i<NCH; i++)
  371.                             if (ctable[i]==0)
  372.                                 {
  373.                                 while (chused[kr
  374. ] == 0)
  375.                                     kr++;
  376.                                 ctable[i]=kr;
  377.                                 chused[kr]=1;
  378.                                 }
  379.                         }
  380.                         lgate();
  381.                         continue;
  382.                     case 'r': case 'R':
  383.                         c = 'r';
  384.                     case 'c': case 'C':
  385.                         if(lgatflg)
  386.                             error("Too late for lang
  387. uage specifier");
  388.                         ratfor = (c == 'r');
  389.                         continue;
  390.                     case '{':
  391.                         lgate();
  392.                         while(getl(p) && scomp(p,"%}") !
  393. = 0)
  394.                             fprintf(fout, "%s\n",p);
  395.                         if(p[0] == '%') continue;
  396.                         error("Premature eof");
  397.                     case 's': case 'S':        /* start
  398.  conditions */
  399.                         lgate();
  400.                         while(*p && index(*p," \t,") < 0
  401. ) p++;
  402.                         n = TRUE;
  403.                         while(n){
  404.                             while(*p && index(*p," \
  405. t,") >= 0) p++;
  406.                             t = p;
  407.                             while(*p && index(*p," \
  408. t,") < 0)p++;
  409.                             if(!*p) n = FALSE;
  410.                             *p++ = 0;
  411.                             if (*t == 0) continue;
  412.                             i = sptr*2;
  413.                             if(!ratfor)fprintf(fout,
  414. "# ");
  415.                             fprintf(fout,"define %s 
  416. %d\n",t,i);
  417.                             scopy(t,sp);
  418.                             sname[sptr++] = sp;
  419.                             sname[sptr] = 0;    /
  420. * required by lookup */
  421.                             if(sptr >= STARTSIZE)
  422.                                 error("Too many 
  423. start conditions");
  424.                             sp += slength(sp) + 1;
  425.                             if(sp >= schar+STARTCHAR
  426. )
  427.                                 error("Start con
  428. ditions too long");
  429.                             }
  430.                         continue;
  431.                     default:
  432.                         warning("Invalid request %s",p);
  433.                         continue;
  434.                         }    /* end of switch after s
  435. eeing '%' */
  436.                 case ' ': case '\t':        /* must be code 
  437. */
  438.                     lgate();
  439.                     fprintf(fout, "%s\n",p);
  440.                     continue;
  441.                 default:        /* definition */
  442.                     while(*p && !space(*p)) p++;
  443.                     if(*p == 0)
  444.                         continue;
  445.                     prev = *p;
  446.                     *p = 0;
  447.                     bptr = p+1;
  448.                     yylval = buf;
  449.                     if(digit(buf[0]))
  450.                         warning("Substitution strings ma
  451. y not begin with digits");
  452.                     return(freturn(STR));
  453.                     }
  454.                 }
  455.             /* still sect 1, but prev != '\n' */
  456.             else {
  457.                 p = bptr;
  458.                 while(*p && space(*p)) p++;
  459.                 if(*p == 0)
  460.                     warning("No translation given - null str
  461. ing assumed");
  462.                 scopy(p,token);
  463.                 yylval = token;
  464.                 prev = '\n';
  465.                 return(freturn(STR));
  466.                 }
  467.             }
  468.         /* end of section one processing */
  469.         }
  470.     else if(sect == RULESECTION){        /* rules and actions */
  471.         while(!eof){
  472.             switch(c=gch()){
  473.             case '\0':
  474.                 return(freturn(0));
  475.             case '\n':
  476.                 if(prev == '\n') continue;
  477.                 x = NEWE;
  478.                 break;
  479.             case ' ':
  480.             case '\t':
  481.                 if(sectbegin == TRUE){
  482.                     cpyact();
  483.                     while((c=gch()) && c != '\n');
  484.                     continue;
  485.                     }
  486.                 if(!funcflag)phead2();
  487.                 funcflag = TRUE;
  488.                 if(ratfor)fprintf(fout,"%d\n",30000+casecount);
  489.                 else fprintf(fout,"case %d:\n",casecount);
  490.                 if(cpyact()){
  491.                     if(ratfor)fprintf(fout,"goto 30997\n");
  492.                     else fprintf(fout,"break;\n");
  493.                     }
  494.                 while((c=gch()) && c != '\n');
  495.                 if(peek == ' ' || peek == '\t' || sectbegin == T
  496. RUE){
  497.                     warning("Executable statements should oc
  498. cur right after %%");
  499.                     continue;
  500.                     }
  501.                 x = NEWE;
  502.                 break;
  503.             case '%':
  504.                 if(prev != '\n') goto character;
  505.                 if(peek == '{'){    /* included code */
  506.                     getl(buf);
  507.                     while(!eof && getl(buf) && scomp("%}",bu
  508. f) != 0)
  509.                         fprintf(fout,"%s\n",buf);
  510.                     continue;
  511.                     }
  512.                 if(peek == '%'){
  513.                     c = gch();
  514.                     c = gch();
  515.                     x = DELIM;
  516.                     break;
  517.                     }
  518.                 goto character;
  519.             case '|':
  520.                 if(peek == ' ' || peek == '\t' || peek == '\n'){
  521.                     if(ratfor)fprintf(fout,"%d\n",30000+case
  522. count++);
  523.                     else fprintf(fout,"case %d:\n",casecount
  524. ++);
  525.                     continue;
  526.                     }
  527.                 x = '|';
  528.                 break;
  529.             case '$':
  530.                 if(peek == '\n' || peek == ' ' || peek == '\t' |
  531. | peek == '|' || peek == '/'){
  532.                     x = c;
  533.                     break;
  534.                     }
  535.                 goto character;
  536.             case '^':
  537.                 if(prev != '\n' && scon != TRUE) goto character;
  538.     /* valid only at line begin */
  539.                 x = c;
  540.                 break;
  541.             case '?':
  542.             case '+':
  543.             case '.':
  544.             case '*':
  545.             case '(':
  546.             case ')':
  547.             case ',':
  548.             case '/':
  549.                 x = c;
  550.                 break;
  551.             case '}':
  552.                 iter = FALSE;
  553.                 x = c;
  554.                 break;
  555.             case '{':    /* either iteration or definition */
  556.                 if(digit(c=gch())){    /* iteration */
  557.                     iter = TRUE;
  558.                 ieval:
  559.                     i = 0;
  560.                     while(digit(c)){
  561.                         token[i++] = c;
  562.                         c = gch();
  563.                         }
  564.                     token[i] = 0;
  565.                     yylval = siconv(token);
  566.                     munput('c',c);
  567.                     x = ITER;
  568.                     break;
  569.                     }
  570.                 else {        /* definition */
  571.                     i = 0;
  572.                     while(c && c!='}'){
  573.                         token[i++] = c;
  574.                         c = gch();
  575.                         }
  576.                     token[i] = 0;
  577.                     i = lookup(token,def);
  578.                     if(i < 0)
  579.                         warning("Definition %s not found
  580. ",token);
  581.                     else
  582.                         munput('s',subs[i]);
  583.                     continue;
  584.                     }
  585.             case '<':        /* start condition ? */
  586.                 if(prev != '\n')        /* not at line b
  587. egin, not start */
  588.                     goto character;
  589.                 t = slptr;
  590.                 do {
  591.                     i = 0;
  592.                     c = gch();
  593.                     while(c != ',' && c && c != '>'){
  594.                         token[i++] = c;
  595.                         c = gch();
  596.                         }
  597.                     token[i] = 0;
  598.                     if(i == 0)
  599.                         goto character;
  600.                     i = lookup(token,sname);
  601.                     if(i < 0) {
  602.                         warning("Undefined start conditi
  603. on %s",token);
  604.                         continue;
  605.                         }
  606.                     *slptr++ = i+1;
  607.                     } while(c && c != '>');
  608.                 *slptr++ = 0;
  609.                 /* check if previous value re-usable */
  610.                 for (xp=slist; xp<t; )
  611.                     {
  612.                     if (strcmp(xp, t)==0)
  613.                         break;
  614.                     while (*xp++);
  615.                     }
  616.                 if (xp<t)
  617.                     {
  618.                     /* re-use previous pointer to string */
  619.                     slptr=t;
  620.                     t=xp;
  621.                     }
  622.                 if(slptr > slist+STARTSIZE)        /* note 
  623. not packed ! */
  624.                     error("Too many start conditions used");
  625.                 yylval = t;
  626.                 x = SCON;
  627.                 break;
  628.             case '"':
  629.                 i = 0;
  630.                 while((c=gch()) && c != '"' && c != '\n'){
  631.                     if(c == '\\') c = usescape(c=gch());
  632.                     token[i++] = c;
  633.                     if(i > TOKENSIZE){
  634.                         warning("String too long");
  635.                         i = TOKENSIZE-1;
  636.                         break;
  637.                         }
  638.                     }
  639.                 if(c == '\n') {
  640.                     yyline--;
  641.                     warning("Non-terminated string");
  642.                     yyline++;
  643.                     }
  644.                 token[i] = 0;
  645.                 if(i == 0)x = NULLS;
  646.                 else if(i == 1){
  647.                     yylval = token[0];
  648.                     x = CHAR;
  649.                     }
  650.                 else {
  651.                     yylval = token;
  652.                     x = STR;
  653.                     }
  654.                 break;
  655.             case '[':
  656.                 for(i=1;i<NCH;i++) symbol[i] = 0;
  657.                 x = CCL;
  658.                 if((c = gch()) == '^'){
  659.                     x = NCCL;
  660.                     c = gch();
  661.                     }
  662.                 while(c != ']' && c){
  663.                     if(c == '\\') c = usescape(c=gch());
  664.                     symbol[c] = 1;
  665.                     j = c;
  666.                     if((c=gch()) == '-' && peek != ']'){        /
  667. * range specified */
  668.                         c = gch();
  669.                         if(c == '\\') c = usescape(c=gch
  670. ());
  671.                         k = c;
  672.                         if(j > k) {
  673.                             n = j;
  674.                             j = k;
  675.                             k = n;
  676.                             }
  677.                         if(!(('A' <= j && k <= 'Z') ||
  678.                              ('a' <= j && k <= 'z') ||
  679.                              ('0' <= j && k <= '9')))
  680.                             warning("Non-portable Ch
  681. aracter Class");
  682.                         for(n=j+1;n<=k;n++)
  683.                             symbol[n] = 1;        /
  684. * implementation dependent */
  685.                         c = gch();
  686.                         }
  687.                     }
  688.                 /* try to pack ccl's */
  689.                 i = 0;
  690.                 for(j=0;j<NCH;j++)
  691.                     if(symbol[j])token[i++] = j;
  692.                 token[i] = 0;
  693.                 p = ccptr;
  694.                 if(optim){
  695.                     p = ccl;
  696.                     while(p <ccptr && scomp(token,p) != 0)p+
  697. +;
  698.                     }
  699.                 if(p < ccptr)    /* found it */
  700.                     yylval = p;
  701.                 else {
  702.                     yylval = ccptr;
  703.                     scopy(token,ccptr);
  704.                     ccptr += slength(token) + 1;
  705.                     if(ccptr >= ccl+CCLSIZE)
  706.                         error("Too many large character 
  707. classes");
  708.                     }
  709.                 cclinter(x==CCL);
  710.                 break;
  711.             case '\\':
  712.                 c = usescape(c=gch());
  713.             default:
  714.             character:
  715.                 if(iter){    /* second part of an iteration *
  716. /
  717.                     iter = FALSE;
  718.                     if('0' <= c && c <= '9')
  719.                         goto ieval;
  720.                     }
  721.                 if(alpha(peek)){
  722.                     i = 0;
  723.                     yylval = token;
  724.                     token[i++] = c;
  725.                     while(alpha(peek))
  726.                         token[i++] = gch();
  727.                     if(peek == '?' || peek == '*' || peek ==
  728.  '+')
  729.                         munput('c',token[--i]);
  730.                     token[i] = 0;
  731.                     if(i == 1){
  732.                         yylval = token[0];
  733.                         x = CHAR;
  734.                         }
  735.                     else x = STR;
  736.                     }
  737.                 else {
  738.                     yylval = c;
  739.                     x = CHAR;
  740.                     }
  741.                 }
  742.             scon = FALSE;
  743.             if(x == SCON)scon = TRUE;
  744.             sectbegin = FALSE;
  745.             return(freturn(x));
  746.             }
  747.         }
  748.     /* section three */
  749.     ptail();
  750. # ifdef DEBUG
  751.     if(debug)
  752.         fprintf(fout,"\n/*this comes from section three - debug */\n");
  753. # endif
  754.     while(getl(buf) && !eof)
  755.         fprintf(fout,"%s\n",buf);
  756.     return(freturn(0));
  757.     }
  758. /* end of yylex */
  759. # ifdef DEBUG
  760. freturn(i)
  761.   int i; {
  762.     if(yydebug) {
  763.         printf("now return ");
  764.         if(i < NCH) allprint(i);
  765.         else printf("%d",i);
  766.         printf("   yylval = ");
  767.         switch(i){
  768.             case STR: case CCL: case NCCL:
  769.                 strpt(yylval);
  770.                 break;
  771.             case CHAR:
  772.                 allprint(yylval);
  773.                 break;
  774.             default:
  775.                 printf("%d",yylval);
  776.                 break;
  777.             }
  778.         putchar('\n');
  779.         }
  780.     return(i);
  781.     }
  782. # endif
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.